package com.zd.kids.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zd.kids.DataBean.TestTrainWordResultDataBean;
import com.zd.kids.DataBean.TrainResultDataBean;
import com.zd.kids.R;

import java.util.List;

import androidx.annotation.Nullable;

/**
 * @ClassName: com.zd.kids.ui.adapter
 * @Description:
 * @Author: hyy
 * @Date: 2020/6/17
 * @Time: 8:54 PM
 */
public class TrainResultAdapter extends BaseQuickAdapter<TestTrainWordResultDataBean, BaseViewHolder> {


    public TrainResultAdapter(@Nullable List<TestTrainWordResultDataBean> data) {
        super(R.layout.activity_train_result_item, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, TestTrainWordResultDataBean item) {

        ImageView img_score = helper.getView(R.id.img_score);

        LinearLayout ll_socre_detail = helper.getView(R.id.ll_socre_detail);

        ImageView img_add = helper.getView(R.id.img_add);
        img_add.setOnClickListener(view -> {
            ll_socre_detail.setVisibility(ll_socre_detail.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
        });

        TextView tv_title = helper.getView(R.id.tv_title);
        tv_title.setText(item.getWord());

        TextView tv_pinyin = helper.getView(R.id.tv_pinyin);
        tv_pinyin.setText(item.getPinyin());

        TextView tv_score = helper.getView(R.id.tv_score);
        tv_score.setText(item.getTotal_score() + "分");

        if (item.getTotal_score() >= 80) {
            img_score.setImageResource(R.mipmap.ic_score_good);
        } else if (item.getTotal_score() >= 60 && item.getTotal_score() < 80) {
            img_score.setImageResource(R.mipmap.ic_score_nomal);
        } else {
            img_score.setImageResource(R.mipmap.ic_score_low);
        }


        ProgressBar record_pb_sm = helper.getView(R.id.record_pb_sm);
        record_pb_sm.setProgress(item.getSm_score());

        ProgressBar record_pb_yd = helper.getView(R.id.record_pb_yd);
        record_pb_yd.setProgress(item.getSd_score());

        ProgressBar record_pb_ym = helper.getView(R.id.record_pb_ym);
        record_pb_ym.setProgress(item.getYm_score());

        TextView tv_score_sm = helper.getView(R.id.tv_score_sm);
        tv_score_sm.setText(item.getSm_score() + "%");

        TextView tv_score_yd = helper.getView(R.id.tv_score_yd);
        tv_score_yd.setText(item.getSd_score() + "%");

        TextView tv_score_ym = helper.getView(R.id.tv_score_ym);
        tv_score_ym.setText(item.getYm_score() + "%");


    }
}
